package com.sansi.pencilbook.service.impl;

import com.sansi.pencilbook.DO.Result;
import com.sansi.pencilbook.entity.Category;
import com.sansi.pencilbook.entity.UseCategory;
import com.sansi.pencilbook.mapper.UseCategoryMapper;
import com.sansi.pencilbook.service.UseCategoryServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;

/**
 * 功能说明:
 *
 * @author lsy13
 */
@Service
public class UseCategoryServerImpl implements UseCategoryServer {

    @Autowired
    private UseCategoryMapper useCategoryMapper;

    @Override
    public Result getAllCategory() {
        try {
            List<UseCategory> list = useCategoryMapper.findAll();
            return list.size()>0 ? Result.ofSuccess("查询类别成功", list.size(), list) :
                    Result.ofFailed("没有类别存在");
        } catch (Exception throwables) {
            System.out.println(throwables.getMessage());
            return Result.ofFailed("查询类别失败");
        }
    }
}
